package com.orange.homescreen.pil.defaultimpl;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;

import com.orange.homescreen.pil.NotificationSummaryInterface;
import com.orange.homescreen.pil.PILMonitorManager;
import com.orange.homescreen.pil.base.BasePILInterfaceImpl;
import com.orange.homescreen.pil.base.BasePILMonitor;
import com.orange.homescreen.pil.defaultimpl.NotificationSummary.NotificationCallsMonitor;
import com.orange.homescreen.pil.defaultimpl.NotificationSummary.NotificationMessageMonitor;
import com.orange.homescreen.pil.defaultimpl.NotificationSummary.NotificationMonitor;
import com.orange.homescreen.pil.defaultimpl.datetime.DateMonitor;
import com.orange.homescreen.pil.defaultimpl.datetime.TimeMonitor;
import com.orange.notificationsummary.event.MessageInfo;
import com.orange.notificationsummary.event.db.MessagesDBHelper;
import com.orange.notificationsummary.event.db.MissedCallDBHelper;
import com.orange.notificationsummary.event.db.NotificationDBHelper;
import com.orange.notificationsummary.event.db.VoiceMailDBHelper;
import com.orange.notificationsummary.event.pil.defaultimpl.BaseEvent;

public class NotificationSummaryInterfaceImpl extends BasePILInterfaceImpl
		implements NotificationSummaryInterface {

	@Override
	public Class<?> getPILInterfaceClass() {
		return NotificationSummaryInterface.class;
	}

	@Override
	public BasePILMonitor getContactsMonitor(Context context) {
		BasePILMonitor monitor = PILMonitorManager
				.getMonitor(NotificationMonitor.class);
		if (monitor == null) {
			monitor = new NotificationMonitor(context);
			PILMonitorManager.registerMonitor(monitor);
		}
		return monitor;
	}

	@Override
	public BasePILMonitor getDateMonitor(Context context) {
		BasePILMonitor monitor = PILMonitorManager
				.getMonitor(TimeMonitor.class);
		if (monitor == null) {
			monitor = new TimeMonitor(context);
			PILMonitorManager.registerMonitor(monitor);
		}
		return monitor;
	}

	@Override
	public BasePILMonitor getTimeMonitor(Context context) {
		BasePILMonitor monitor = PILMonitorManager
				.getMonitor(DateMonitor.class);
		if (monitor == null) {
			monitor = new DateMonitor(context);
			PILMonitorManager.registerMonitor(monitor);
		}
		return monitor;
	}

	@Override
	public BasePILMonitor getMissedCallMonitor(Context context) {
		BasePILMonitor monitor = PILMonitorManager
				.getMonitor(NotificationCallsMonitor.class);
		if (monitor == null) {
			monitor = new NotificationCallsMonitor(context);
			PILMonitorManager.registerMonitor(monitor);
		}
		return monitor;
	}

	@Override
	public BasePILMonitor getUnreadMsgMonitor(Context context) {
		BasePILMonitor monitor = PILMonitorManager
				.getMonitor(NotificationMessageMonitor.class);
		if (monitor == null) {
			monitor = new NotificationMessageMonitor(context);
			PILMonitorManager.registerMonitor(monitor);
		}
		return monitor;
	}

	@Override
	public boolean insertCallLog(Context context, BaseEvent missedCallInfo) {
		return MissedCallDBHelper.insertCallLog(context, missedCallInfo);
	}

	@Override
	public boolean updateSMSStatusById(Context context, String id) {
		return MessagesDBHelper.updateSMSStatusById(context, id);
	}

	@Override
	public int getMissedCallCount(Context context) {
		return 0;
	}

	@Override
	public List<BaseEvent> getMissedCallList(Context context) {
		return MissedCallDBHelper.getAllMissedCallEvent(context);
	}

	@Override
	public int getUnreadMessageCount(Context context) {
		return 0;
	}

	@Override
	public List<BaseEvent> getUnreadMessageList(Context context) {
		return MessagesDBHelper.getAllUnreadMessageEvent(context);
	}

	@Override
	public int getVoiceMailCount(Context context) {
		return VoiceMailDBHelper.getVoiceMailInfoCount(context);
	}

	@Override
	public List<BaseEvent> getVoiceMailList(Context context) {
		return VoiceMailDBHelper.getVoiceMailInfo(context);
	}

	@Override
	public Cursor getMissedCallCursor(Context context) {
		return MissedCallDBHelper.queryMissedCallInfo(context);
	}

	@Override
	public String[] getMissCallIDsByNumber(String phoneNumber, Context context) {
		return MissedCallDBHelper.getIdsByNumber(phoneNumber, context);
	}

	@Override
	public boolean updateMissCallStatusByIds(Context context, String[] ids) {
		return NotificationDBHelper.updateCallLogStatusByIds(context, ids);
	}

	@Override
	public List<MessageInfo> getUnreadMmsInfo(Context context) {
		return MessagesDBHelper.getUnreadMmsInfo(context);
	}

	@Override
	public List<MessageInfo> getUnreadSmsInfo(Context context) {
		return MessagesDBHelper.getUnreadSmsInfo(context);
	}

	@Override
	public List<MessageInfo> getUnreadMmsSmsInfo(Context context) {
		return MessagesDBHelper.getUnreadMmsSmsInfo(context);
	}

	@Override
	public String getDisplayNameByNumber(Context context, String number) {
		return NotificationDBHelper.getDisplayNameByNumber(context, number);
	}

	@Override
	public Cursor getThreadsInfoCursor(Context context) {
		return MessagesDBHelper.getThreadsInfoCursor(context);
	}

	@Override
	public Cursor getVoiceMailCursor(Context context) {
		return VoiceMailDBHelper.getVoiceMailCursor(context);
	}

	@Override
	public int updateMissCallStatusByNumber(Context context, String columnName,
			String columnValue) {
		return MissedCallDBHelper.updateMissCallStatusByNumber(context,
				columnName, columnValue);
	}

	@Override
	public Map<String, Integer> getAttachmentCountInMMSDetailed(
			Context context, String mId) {
		return MessagesDBHelper.getAttachementCount(context, mId);
	}

	@Override
	public List<BaseEvent> getAllMissedCallEvent(Context context) {
		return MissedCallDBHelper.getAllMissedCallEvent(context);
	}

	@Override
	public String[] getIdsByNumber(String phoneNumber, Context context) {
		return MissedCallDBHelper.getIdsByNumber(phoneNumber, context);
	}

	@Override
	public boolean updateCallLogStatusByIds(Context context, String[] _ids) {
		return NotificationDBHelper.updateCallLogStatusByIds(context, _ids);
	}

	@Override
	public List<BaseEvent> getAllUnreadMessageEvent(Context context) {
		return MessagesDBHelper.getAllUnreadMessageEvent(context);
	}

	@Override
	public String getMMSContentLocationUrl(Context context, String id) {
		return MessagesDBHelper.getMMSContentLocationUrl(context, id);
	}

	@Override
	public int getVoiceMailInfoCount(Context context) {
		return VoiceMailDBHelper.getVoiceMailInfoCount(context);
	}

	@Override
	public boolean updateUnreadMsgStatusByThreadIds(Context context,
			String[] threadIds) {
		return NotificationDBHelper.updateUnreadMsgStatusByThreadIds(context,
				threadIds);
	}

	@Override
	public Bitmap getMmsPhotobyMmsId(Context context, String id) {
		return MessagesDBHelper.getMmsPhotobyMmsId(context, id);
	}

	@Override
	public String getMmsTextContent(Context context, String id) {
		return MessagesDBHelper.getMmsTextContent(context, id);
	}

	@Override
	public String getSmsNumber(Context context, String id) {
		return MessagesDBHelper.getSmsNumber(context, id);
	}

	@Override
	public boolean updateVVMStatusByIds(Context context, String[] ids) {
		return VoiceMailDBHelper.updateVVMStatusByIds(context, ids);
	}
}
